package config

import (
	"fmt"

	"github.com/spf13/viper"
)

type Mysql struct {
	Host     string
	Port     int
	Username string
	Password string
	Database string
}

type AppConfig struct {
	Mysql Mysql
}

var AppConf AppConfig

func Init() {
	viper.SetConfigFile("config/dev.yaml")

	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		panic(err)
	}
	fmt.Println("获取配置文件成功", AppConf)

}
